import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:String类练习
 * User: dings
 * Date: 2024-04-24
 * Time: 10:34
 */
public class Test {
    public static String reverse(String str,int begin, int end) {
        char[] arr = str.toCharArray();
        while (begin < end) {
            char tmp = arr[begin];
            arr[begin] = arr[end];
            arr[end] = tmp;
            begin++;
            end--;
        }
        //return new String(arr);
        return String.copyValueOf(arr);
    }
    public static void main(String[] args) {
        String str = "abcd";
        String ret = reverse(str,0,str.length()-1);
        System.out.println(ret);
    }
    public static void main4(String[] args) {
        String name = "dfda&jkf=df12";
        String[] newStr = name.split("&");
        for (String s:newStr) {
            //经过调试发现，每次进入循环，
            // newStr2数组会重新创建，之前存储的值会销毁
            String[] newStr2 = s.split("=");
            for (String S:newStr2) {
                System.out.println(S);
            }
        }
    }
    public static boolean func(String str)
    {
        char[] arr = str.toCharArray();
        for (int i = 0; i < str.length(); i++) {
            if(arr[i] < '0' || arr[i] > '9')
                return false;
        }
        return true;
    }
    public static void main3(String[] args) {
        String str ="12445456aa57343";
        boolean flg = func(str);
        System.out.println(flg);
    }
    public static void main2(String[] args) {
        String str1 = "abcd";
        char[] arr = str1.toCharArray();
        System.out.println(Arrays.toString(arr));
    }
    public static void main1(String[] args) {
        String str1 = "hello";
        String str2 = "hell" + "o";
        String str3 = new String("hello");
        String str4 = new String("hell") + "o";
        System.out.println(str1 == str2);//ture
        System.out.println(str1 == str3);//false
        System.out.println(str3 == str4);//false
        System.out.println();
    }
}
